package com.itheima.list;

import java.util.*;

/**
 * List 的增删改查
 * 操作索引: 不能操作不存在的额索引
 * add()
 * add()带索引
 * remove
 * remove
 * set
 *get
 *
 */
public class Test02 {
    public static void main(String[] args) {
        //创建集合
        List<String> list= new ArrayList<>();
        //添加元素
        //add()
        list.add(0,"鹿晗");
        list.add(1,"蔡徐坤");
        list.add(0,"关晓彤");

       // list.add(10,"谢广坤");
        //add()插队
        System.out.println(list);
        //remove()

        //remove根据索引删除
        //String remove = list.remove(3);
        String remove1 = list.remove(2);
        //System.out.println(remove);
        System.out.println(remove1);
        System.out.println(list);
        //set 设置
        String guan = list.set(0, "谢大脚");
        System.out.println(guan);
        System.out.println(list);
        //获取
        System.out.println(list.get(0));
        System.out.println(list.get(1));




    }


}
